//
//  UDLoginManager.m
//  UnitDemo
//
//  Created by wangqinglu on 15/11/10.
//  Copyright © 2015年 xs. All rights reserved.
//

#import "UDLoginManager.h"
// in *.m
NSString* const UDLOGINMANAGER_NOTIFICATION_SIGNIN_SUCCESS = @"UDLoginManagerNotificationSignInSuccess";
@interface UDLoginManager () {
    BOOL g_isLogged;
}

@end

@implementation UDLoginManager
@synthesize isLogged = g_isLogged;
+(UDLoginManager *) sharedInstance {
    static UDLoginManager *singleton;
    static dispatch_once_t token;
    dispatch_once(&token,^{
        singleton = [[UDLoginManager alloc] initSingle];
    });
    return singleton;
//    return nil;
}

-(id) initSingle {
    self = [super init];
    if (self) {
        
    }
    return self;
}

-(void) signInWithUserName:(NSString*)username Password:(NSString*)psw {
    g_isLogged = YES;
    
    dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_async(concurrentQueue, ^{
        [[NSNotificationCenter defaultCenter] postNotificationName:UDLOGINMANAGER_NOTIFICATION_SIGNIN_SUCCESS object:nil userInfo:nil];
    });
}

-(void) logout {
    g_isLogged = NO;
}
@end
